<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveSupport::Dependencies::ClassCache</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            ActiveSupport::Dependencies::ClassCache 
            
                <span class="parent">&lt; 
                    
                    <a href="../../Object.html">Object</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/activesupport/lib/active_support/dependencies_rb.html">activesupport/lib/active_support/dependencies.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassCache.html#method-i-5B-5D">[]</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassCache.html#method-i-clear-21">clear!</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassCache.html#method-i-empty-3F">empty?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>G</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassCache.html#method-i-get">get</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>K</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassCache.html#method-i-key-3F">key?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassCache.html#method-c-new">new</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassCache.html#method-i-safe_get">safe_get</a>,
              </li>
            
              
              <li>
                <a href="ClassCache.html#method-i-store">store</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-new">
            
              <b>new</b>()
            
            <a href="ClassCache.html#method-c-new" name="method-c-new" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/45448a578877f6a753492113d72cc3512a6f1720/activesupport/lib/active_support/dependencies.rb#L520" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/dependencies.rb, line 520</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>
  <span class="ruby-ivar">@store</span> = <span class="ruby-constant">ThreadSafe</span><span class="ruby-operator">::</span><span class="ruby-constant">Cache</span>.<span class="ruby-identifier">new</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-5B-5D">
            
              <b>[]</b>(key)
            
            <a href="ClassCache.html#method-i-5B-5D" name="method-i-5B-5D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-clear-21">
            
              <b>clear!</b>()
            
            <a href="ClassCache.html#method-i-clear-21" name="method-i-clear-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-clear-21_source')" id="l_method-i-clear-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/45448a578877f6a753492113d72cc3512a6f1720/activesupport/lib/active_support/dependencies.rb#L550" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-clear-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/dependencies.rb, line 550</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">clear!</span>
  <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">clear</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-empty-3F">
            
              <b>empty?</b>()
            
            <a href="ClassCache.html#method-i-empty-3F" name="method-i-empty-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-empty-3F_source')" id="l_method-i-empty-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/45448a578877f6a753492113d72cc3512a6f1720/activesupport/lib/active_support/dependencies.rb#L524" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-empty-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/dependencies.rb, line 524</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">empty?</span>
  <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-get">
            
              <b>get</b>(key)
            
            <a href="ClassCache.html#method-i-get" name="method-i-get" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="ClassCache.html#method-i-5B-5D">[]</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-get_source')" id="l_method-i-get_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/45448a578877f6a753492113d72cc3512a6f1720/activesupport/lib/active_support/dependencies.rb#L532" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-get_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/dependencies.rb, line 532</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">get</span>(<span class="ruby-identifier">key</span>)
  <span class="ruby-identifier">key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:name</span>)
  <span class="ruby-ivar">@store</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Inflector</span>.<span class="ruby-identifier">constantize</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-key-3F">
            
              <b>key?</b>(key)
            
            <a href="ClassCache.html#method-i-key-3F" name="method-i-key-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-key-3F_source')" id="l_method-i-key-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/45448a578877f6a753492113d72cc3512a6f1720/activesupport/lib/active_support/dependencies.rb#L528" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-key-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/dependencies.rb, line 528</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">key?</span>(<span class="ruby-identifier">key</span>)
  <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-safe_get">
            
              <b>safe_get</b>(key)
            
            <a href="ClassCache.html#method-i-safe_get" name="method-i-safe_get" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-safe_get_source')" id="l_method-i-safe_get_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/45448a578877f6a753492113d72cc3512a6f1720/activesupport/lib/active_support/dependencies.rb#L538" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-safe_get_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/dependencies.rb, line 538</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">safe_get</span>(<span class="ruby-identifier">key</span>)
  <span class="ruby-identifier">key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:name</span>)
  <span class="ruby-ivar">@store</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Inflector</span>.<span class="ruby-identifier">safe_constantize</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-store">
            
              <b>store</b>(klass)
            
            <a href="ClassCache.html#method-i-store" name="method-i-store" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-store_source')" id="l_method-i-store_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/45448a578877f6a753492113d72cc3512a6f1720/activesupport/lib/active_support/dependencies.rb#L543" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-store_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/dependencies.rb, line 543</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">store</span>(<span class="ruby-identifier">klass</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:name</span>)
  <span class="ruby-identifier">raise</span>(<span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">'anonymous classes cannot be cached'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-ivar">@store</span>[<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">klass</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    